<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.7.9/vue.js"></script>
</head>

<body>
    <div id="app">
        用户名：<input type="text" :value="userName" @input="change($event,'userName')">
        <br />
        密码：<input type="text" :value="passWord" @input="change($event,'passWord')">
        <br />
        <button>登录</button>
    </div>
    <script>
        new Vue({
            el: '#app',
            data: {
                userName: 'admin',
                passWord: '123456',
                key: ''
            },
            methods: {
                change(e, val) {
                    this[val] = e.target.value
                }
            }
        })
    </script>
</body>

</html>